export function successReturn(data:any = null, msg:string = '请求成功', statusCode:number = 200) {
  return {
      success : true,
      data,
      msg,
      statusCode
  }
}

export function errorReturn(msg:string = '请求失败', statusCode:number = 400, data:any = null) {
  return {
      success : false,
      data,
      msg,
      statusCode
  }
}

export function getTime() : number{
    return Math.floor((new Date()).getTime() / 1000)
}

export function numToHex(num:number, len:number) {
  let hex = num.toString(16)
  return hex.padStart(len, '0')
}

export function strToHex(str:string, len:number) {
  let hex = ''
  if(str !== '') {
      for(let i = 0; i < str.length; i ++) {
          hex += (str.charCodeAt(i).toString(16))
      }
  }

  return hex.padStart(len, '0')    
}